#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

sys.path.insert(0, '.')

import unittest
import os
import re

test_modules = []
_p_test_filename = re.compile(r'^test_.+\.py$')

def _add_test(_, dirname, names):
    for f in names:
        if _p_test_filename.match(f):
            pkg_name = dirname.split('/')
            pkg_name.append(os.path.splitext(f)[0])

            test_modules.append('.'.join(pkg_name))


def main():
    os.path.walk('test', _add_test, None)
    suite = unittest.TestSuite()
    print test_modules
    suite.addTest(unittest.defaultTestLoader.loadTestsFromNames(test_modules))
    unittest.TextTestRunner(verbosity=2).run(suite)

if __name__ == '__main__':
    main()
